package com.zxk.blog.service.impl;


import com.zxk.blog.service.EsDataRestTemplateService;
import com.zxk.core.common.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.net.URISyntaxException;

@Service
public class EsDataRestTemplateServiceImpl implements EsDataRestTemplateService {

    @Autowired
    private RestTemplate restTemplate;
    @Override
    public JsonData esDataProvider(String index, String field, String keyword, Integer pageNo, Integer pageSize) {
        try {
            URI uri = new URI("http://47.105.178.63:9998/get/"+index+"/"+field+"/"+keyword+"/"+pageNo+"/"+pageSize);
            JsonData jsonData = restTemplate.postForObject(uri, null, JsonData.class);
            return  jsonData;
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return null;
    }
}
